package com.ruoyi.energy.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.energy.mapper.TcParkingLeaseMapper;
import com.ruoyi.energy.domain.TcParkingLease;
import com.ruoyi.energy.service.ITcParkingLeaseService;

/**
 * 车位租赁Service业务层处理
 *
 * @author cjie
 * @date 2021-07-29
 */
@Service
public class TcParkingLeaseServiceImpl implements ITcParkingLeaseService {
    @Autowired
    private TcParkingLeaseMapper tcParkingLeaseMapper;

    /**
     * 查询车位租赁
     *
     * @param id 车位租赁ID
     * @return 车位租赁
     */
    @Override
    public TcParkingLease selectTcParkingLeaseById(String id) {
        return tcParkingLeaseMapper.selectTcParkingLeaseById(id);
    }

    /**
     * 查询车位租赁列表
     *
     * @param tcParkingLease 车位租赁
     * @return 车位租赁
     */
    @Override
    public List<TcParkingLease> selectTcParkingLeaseList(TcParkingLease tcParkingLease) {
        return tcParkingLeaseMapper.selectTcParkingLeaseList(tcParkingLease);
    }

    /**
     * 新增车位租赁
     *
     * @param tcParkingLease 车位租赁
     * @return 结果
     */
    @Override
    public int insertTcParkingLease(TcParkingLease tcParkingLease) {
        tcParkingLease.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        tcParkingLease.setCreateTime(DateUtils.getNowDate());
        tcParkingLease.setCreateBy(SecurityUtils.getUsername());
        return tcParkingLeaseMapper.insertTcParkingLease(tcParkingLease);
    }

    /**
     * 修改车位租赁
     *
     * @param tcParkingLease 车位租赁
     * @return 结果
     */
    @Override
    public int updateTcParkingLease(TcParkingLease tcParkingLease) {
        tcParkingLease.setUpdateTime(DateUtils.getNowDate());
        tcParkingLease.setUpdateBy(SecurityUtils.getUsername());
        return tcParkingLeaseMapper.updateTcParkingLease(tcParkingLease);
    }

    /**
     * 批量删除车位租赁
     *
     * @param ids 需要删除的车位租赁ID
     * @return 结果
     */
    @Override
    public int deleteTcParkingLeaseByIds(String[] ids) {
        return tcParkingLeaseMapper.deleteTcParkingLeaseByIds(ids);
    }

    /**
     * 删除车位租赁信息
     *
     * @param id 车位租赁ID
     * @return 结果
     */
    @Override
    public int deleteTcParkingLeaseById(String id) {
        return tcParkingLeaseMapper.deleteTcParkingLeaseById(id);
    }
}
